import { ApiOauthTokenLogin, ApiGetPhoneCode,ApiChangeMemberBaseInfo } from '@/common/request/api/user.js'
const state = {}
const actions = {
	// 微信手机号登录
	async ActLoginWx({dispatch,commit},payload){
		const res = await ApiOauthTokenLogin(payload)
		if(res.access_token){
			// uni.setStorageSync('storeId', '210105001093');
			uni.setStorageSync('token', res.token_type +' '+res.access_token);
			uni.setStorageSync('refresh_token', res.refresh_token);
			uni.setStorageSync('loginEffectTime', new Date().getTime()+res.expires_in*1000)
			uni.setStorageSync('userInfo',res);
		}else{
			uni.showModal({
				content: res.error_description,
				showCancel: false
			});
		}
		return res
	},
	// 获取手机验证码
	async ActGetPhoneCode({dispatch,commit},payload){
		const res = await ApiGetPhoneCode(payload)
		if(res){
		}else{
			uni.showModal({
				content: res.error_description,
				showCancel: false
			});
		}
		return res
	},
	// 完善用户个人基础信息
	async ActChangeMemberBaseInfo({dispatch,commit},payload){
		const res = await ApiChangeMemberBaseInfo(payload)
		if(res.success){
			// commit('USERINFORMATION',res.data)
		}else{
			uni.showModal({
				title: '提示',
				content: res.msg,
				showCancel:false
			});
		}
		return res
	},

}
const mutations ={
	
}
const getters = {
	
}

export default {
	state,
	mutations,
	actions,
	getters
}